<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 作业：封装函数 处理'ababfasbasfbfdbfbafbafb' // 出现最多的符号，次数为几

    let str = 'ababfasbasfbfdbfbafbafb'

    let obj = {}
    let arr = []
    for(let i=0; i<str.length; i++){
      obj[str[i]]?obj[str[i]]++:obj[str[i]]=1
      arr.push(str[i])
    }
    console.log(obj)
    console.log(arr)


    let max = 0
    let n = 0
    for(let k in obj){
      // console.log([k]);
      if(max<obj[k]){
        max=obj[k]
        n = k
      }
     
    }
    // console.log(max,n)
    console.log(`出现最多的符号${n},次数为${max}`)
  </script>
</body>
</html>